<?php

namespace app\api\controller;

use app\api\model\ActivityModel;
use think\Controller;

class Activity extends Controller {
    function atvdetail() {
        $activityid = input('get.activityid');
        $model = new ActivityModel();
        $result = $model->atvdetail($activityid);
        if ($result) {
            return json($result);
        } else {
            return json(['activityid' => 0]);
        }

    }

    function atvlist() {
        $model = new ActivityModel();
        $result = $model->atvlist();
        return json($result);
    }

    function activityenroll() {
        $userid = input('get.userid');
        $activityid = input('get.activityid');

        $model = new ActivityModel();
        $result = $model->activityenroll($userid, $activityid);
        return json($result);
    }

    function collect() {
        $userid = input('get.userid');
        $activityid = input('get.activityid');

        $model = new ActivityModel();
        $result = $model->collect($userid, $activityid);
        return json($result);
    }

    function isCollect() {
        $userid = input('get.userid');
        $activityid = input('get.activityid');

        $model = new ActivityModel();
        $result = $model->isCollect($userid, $activityid);
        return json($result);
    }


    function getReply() {
        $activityid = input('get.activityid');

        $model = new ActivityModel();
        $result = $model->getReply( $activityid);
        return json($result);
    }

    function reply() {
        $activityid = input('get.activityid');
        $userid = input('get.userid');
        $comment = input('get.comment');

        $model = new ActivityModel();
        $result = $model->reply( $userid,$activityid,$comment);
        return json($result);


    }

    public function collectActivityList()
    {
        $userid = input('get.userid');

        $model = new ActivityModel();
        $result = $model->collectActivityList($userid);
        return json($result);
    }
}